﻿/*Di Carbone Carlo
 * carbone05@gmail.com */

using System;
using System.Windows.Forms;

namespace Badge_Manager
{
    public partial class frmConnessioneDB : Form
    {
        public frmConnessioneDB()
        {
            InitializeComponent();
            this.Text = "Connessione DB";
            this.getValori();
        }

        private void getValori()
        {
            txtServer.Text = BadgeManager.Properties.Settings.Default.server.ToString();
            txtDBNome.Text = BadgeManager.Properties.Settings.Default.nomedb.ToString();
            txtUsername.Text = BadgeManager.Properties.Settings.Default.utente.ToString();
            txtPwd.Text = BadgeManager.Properties.Settings.Default.password.ToString();
        }

        private void cmdSalva_Click(object sender, EventArgs e)
        {
            if (txtServer.Text == "" || txtDBNome.Text == ""
                || txtUsername.Text == "" || txtPwd.Text == "")
            {
                MessageBox.Show("I dati sono incompleti!");
                return;
            }

            BadgeManager.Properties.Settings.Default.server = txtServer.Text;
            BadgeManager.Properties.Settings.Default.nomedb = txtDBNome.Text;
            BadgeManager.Properties.Settings.Default.utente = txtUsername.Text;
            BadgeManager.Properties.Settings.Default.password = txtPwd.Text;
            BadgeManager.Properties.Settings.Default.Save();
            this.Close();
        }

        private void cmdAnnulla_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}